package com.wanda.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;



import com.wanda.po.JsonModelGeneral;
import com.wanda.po.Salechance;
import com.wanda.po.SalechanceExample;
import com.wanda.service.SaleChanceService;

@Controller
@RequestMapping("sale")
public class SaleChanceController {

	@Autowired
	private SaleChanceService saleChanceService;
	@RequestMapping("/query")
	public @ResponseBody int queryChance(Salechance salechance)throws Exception{
//		int num=(Integer) session.getAttribute("num");
//		System.out.println("==========="+num);
//		System.out.println("����:"+salechance.getCname());
		int n  = saleChanceService.insert(salechance);
		return n;
	}
	@RequestMapping("/List")
	public @ResponseBody JsonModelGeneral selectList() throws Exception{
		JsonModelGeneral jsonModel = new JsonModelGeneral();
		SalechanceExample example = new SalechanceExample();
		List<Salechance> list = saleChanceService.selectByExample(example);
		jsonModel.setRows(list);
		return jsonModel;
	}
	
	@RequestMapping("/delete")
	public @ResponseBody int deleteChance(Integer id) throws Exception{
		int n = saleChanceService.deleteByPrimaryKey(id);
		return n;
	}
	
	@RequestMapping("/update")
	public @ResponseBody int updateChance(Salechance record) throws Exception{
		int n = saleChanceService.updateByPrimaryKey(record);
		return n;
	}
	
	@RequestMapping("/select")
	public @ResponseBody JsonModelGeneral selectById(Integer id) throws Exception{
		JsonModelGeneral jsonModel = new JsonModelGeneral();
		Object myobj = saleChanceService.selectByPrimaryKey(id);
		jsonModel.setMyobj(myobj);
		return jsonModel;
	}
}
